package com.kuang.springcloud.service;

import com.kuang.springcloud.pojo.User;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
//降级
@Component
public class UserServiceFallbackFactory implements FallbackFactory {

    @Override
    public UserClientService create(Throwable cause) {
        return new UserClientService() {
            @Override
            public Boolean addOne(User user) {
                return null;
            }

            @Override
            public User selectOne(Integer uId) {
                return new User().setUserNo(uId).setUserName("id=>"+uId+"没有对应，这里返回信息降级信息").setDbSource("无数据");
            }

            @Override
            public List<User> selectAll() {
                return null;
            }
        };
    }
}
